#include <stddef.h>
#ifndef N2BASELIB_STRING_POOL_H_9D2202204429CCA7EE0790C38EEE17A6
#define N2BASELIB_STRING_POOL_H_9D2202204429CCA7EE0790C38EEE17A6     1

class TN2StringPool
{
private:
    size_t          alloc_size;
    size_t          curptr;
    size_t          base;
    size_t AddByteData(const char* str, size_t length, int align);
    void   IncPoolSize();
public:
    char *          pool;

    TN2StringPool();
    TN2StringPool(size_t incbase);
    ~TN2StringPool();
    size_t AddStr(const char* str);
    size_t AddUtf16Str(const unsigned short* str);
    size_t AddUtf32Str(const unsigned int* str);
    const char * GetStr(size_t offset);
    const unsigned short * GetUtf16Str(size_t offset);
    const unsigned int * GetUtf32Str(size_t offset);

    size_t GetPoolSize();
    size_t GetUsedSize();
    void ClearPool();
    void ClearAndFreePool();
};

struct TN2DataPoolBlock
{
    unsigned char *     data;
    size_t              blocksize;
    size_t              used;
};

class TN2DataPool
{
private:
    void IncreaseBlockNumber();
public:
    n2ulong_t           datasize;               // the total size of data be write
    TN2DataPoolBlock  * blocks;
    size_t              minBlockSize;
    size_t              block_alloc;            // the number of allocated blocks
    size_t              curblockid;             // the number of used blocks
    size_t              block_base;

    TN2DataPool(size_t minSize, size_t blockbase);
    ~TN2DataPool();
    void AddBinaryData(unsigned char * data, size_t size);
    n2ulong_t GetTotalDataSize();
    void ClearAllData();
};



#endif //











